﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using TechTalk.SpecFlow;

namespace Goblinfactory.NMenu.Specs
{
    [Binding]
    public class DemoSteps
    {
        private int _num;
        [Given(@"some number of 44")]
        public void GivenSomeNumberOf(string num)
        {
            _num = 44;
        }

        private Table _data;
        [Given(@"this sampledata")]
        public void ThisSampleData()
        {
            _data = new Table(new string[] { "ID","Name"} );
            _data.AddRow(new string[]{ "1","Alan" });
            _data.AddRow(new string[] { "2", "Gary" });
        }

        [When(@"I write the bindings for my tests")]
        public void IWriteTheBindingsForMyTests() { /* do nothing */ }

        [Then(@"the first column in the header is ID")]
        public void TheFirstColumnInTheHeaderIs()        {
            Assert.That(_data.Header.ElementAt(0),Is.EqualTo("ID"));
        }

        [Then(@"the second column in the header is Name")]
        public void TheSecondColumnInTheHeaderIs()
        {
            Assert.That(_data.Header.ElementAt(1), Is.EqualTo("Name"));
        }

        [Then(@"the number is 44")]
        public void TheNumberIs(string num) 
        {
            Assert.That(_num, Is.EqualTo(44));
        }

        [Then(@"Gary's ID is 2")]
        public void GarysIdIs()
        {
            TableRow gary = _data.Rows.FirstOrDefault(r => r["Name"] == "Gary");
            Assert.That(gary["ID"], Is.EqualTo("2"));
        }

    } // class
} // namespace
